﻿Public Class TreeNodes : Inherits List(Of TreeNode)

    Public Owner As TreeNode
    Public Tree As TreeView

    Sub New(ByVal Tree As TreeView, ByVal Owner As TreeNode)
        Me.Tree = Tree
        Me.Owner = Owner
    End Sub

    Sub ExpandAll()
        For Each Node In Me
            Node.ExpandAll()
        Next
    End Sub

    Sub CollapseAll()
        For Each Node In Me
            Node.CollapseAll()
        Next
    End Sub

    Function ProcessMouse(ByVal P As Point) As Boolean
        For Each Node In Me
            If Node.ProcessMouse(P) Then Return True
        Next
        Return False
    End Function

    Sub Measure(ByVal G As Graphics, ByVal x As Integer, ByRef y As Integer, ByVal Width As Integer)
        For Each Node In Me
            Node.Measure(G, x, y, Width)
        Next
    End Sub

    Sub DrawLines(ByVal G As Graphics, ByVal R As Rectangle)
        For Each Node In Me
            Node.DrawLines(G, R)
        Next
    End Sub

    Sub Draw(ByVal G As Graphics, ByVal R As Rectangle)
        For Each Node In Me
            Node.Draw(G, R)
        Next
    End Sub

    Function HitTest(ByVal P As Point) As TreeView.HitTestInfo
        For Each Node In Me
            Dim Result = Node.HitTest(P)
            If Not Result Is Nothing Then Return Result
        Next
        Return Nothing
    End Function

    Shadows Sub Clear()
        MyBase.Clear()
        Tree.Invalidate()
    End Sub

End Class